<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:replace="admin/base :: commonHead(_,_)"></head>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.2.0/dist/echarts.min.js"></script>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside th:insert="admin/base :: commonMenu"></aside>
        <!--End 左侧导航-->

        <!--头部信息-->
        <header th:replace="admin/base :: commonHeader"></header>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-primary">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">总阅读量</p>
                                    <p class="h3 text-white m-b-0 fa-1-5x">[[${blogInfoMap.readArticleNum}]]</p>
                                </div>
                                <div class="pull-left"><span class="img-avatar img-avatar-48 bg-translucent"><i
                                        class="mdi mdi-book-open fa-1-5x"></i></span></div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-danger">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">文章数量</p>
                                    <p class="h3 text-white m-b-0 fa-1-5x">[[${blogInfoMap.articleListNum}]]</p>
                                </div>
                                <div class="pull-left"><span class="img-avatar img-avatar-48 bg-translucent"><i
                                        class="mdi mdi-book-open fa-1-5x"></i></span></div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-success">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">评论数量</p>
                                    <p class="h3 text-white m-b-0 fa-1-5x">[[${blogInfoMap.commentsListNum}]]</p>
                                </div>
                                <div class="pull-left"><span class="img-avatar img-avatar-48 bg-translucent"><i
                                        class="mdi mdi-comment-multiple-outline fa-1-5x"></i></span></div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-purple">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">分类数量</p>
                                    <p class="h3 text-white m-b-0 fa-1-5x">[[${blogInfoMap.categoryListNum}]]</p>
                                </div>
                                <div class="pull-left"><span class="img-avatar img-avatar-48 bg-translucent"><i
                                        class="mdi mdi-comment-outline fa-1-5x"></i></span></div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">

                    <div class="col-lg-6">
                        <div class="card">
                            <div class="card-body">
                                <div id="main" style="width: 600px;height:210px;"></div>
                            </div>
                        </div>
                    </div>

                    <div class="col-lg-6">
                        <div class="card">
                            <div class="list-group">
                                <h4 class="list-group-item active">
                                    最新评论:
                                </h4>
                                <a href="#!" class="list-group-item" th:each="comment: ${blogInfoMap.commentsList}">
                                    [[${comment.user.username}]] 对 [[${comment.article.title}]] 评论 "[[${comment.text}]]"
                                </a>
                            </div>
                        </div>
                    </div>

                </div>

                <div class="row">

                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header">
                                <h4>系统操作日志</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                        <tr>
                                            <th>操作日期</th>
                                            <th>操作动作</th>
                                            <th>请求方式</th>
                                            <th>请求参数</th>
                                            <th>用户</th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        <tr th:each="sysLog: ${pageInfo.records}">
                                            <td th:text="${#dates.format(sysLog.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
                                            <td th:text="${sysLog.operation}"></td>
                                            <td th:text="${sysLog.method}"></td>
                                            <td th:text="${sysLog.params}"></td>
                                            <td>
                                                <span class="label label-warning" th:text="${sysLog.username}"></span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <div class="modal-footer no-margin-top">
                                <div class="col-md-6">
                                    <ul class="pagination">
                                        <li><a th:href="${#request.getRequestURI()} + '?pageNum=1'">«</a></li>
                                        <li>
                                            <a th:href="${#request.getRequestURI()} +'?pageNum='+${pageInfo.current - 1}"
                                               th:if="${pageInfo.hasPrevious()}">上一页</a>
                                        </li>
                                        <li>
                                            <a>当前[[${pageInfo.current}]]页</a>
                                        </li>
                                        <li>
                                            <a th:href="${#request.getRequestURI()} +'?pageNum='+${pageInfo.current + 1}"
                                               th:if="${pageInfo.hasNext()}">下一页</a>
                                        </li>
                                        <li>
                                            <a th:href="${#request.getRequestURI()} + '?pageNum='+${pageInfo.pages}">»</a>
                                        </li>

                                    </ul>
                                </div>
                            </div>

                        </div>
                        <!--显示分页信息-->
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
        </aside>
    </div>
</div>
<footer th:replace="admin/base :: commonFooter"></footer>
<script th:inline="javascript">

    var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    var option;

    option = {
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: '1%',
            left: 'center'
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                top: 30,
                itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: '15',
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: [
                    [# th
    :
    each = "item : ${blogInfoMap.categoryMap}"
    ]
    {
        name: '[(${item.getKey().name})]' , value
    :
        [(${item.getValue()})]
    }
    ,
    [/]
    ]
    }
    ]
    }
    ;

    option && myChart.setOption(option);

</script>
</body>
</html>